<!doctype html public "-//w3c//dtd xhtml 1.0 frameset//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-frameset.dtd">
<html>
<head>
    <title>删除用户</title>
    <meta http-equiv=content-type content="text/html; charset=utf-8"/>
    <meta http-equiv=pragma content=no-cache/>
    <meta http-equiv=cache-control content=no-cache/>
    <meta http-equiv=expires content=-1000/>
    <link href="[{$Think.const.ADMIN_CSS_URL}]bootstrap.css" type="text/css" rel="stylesheet"/>
    <link href="[{$Think.const.ADMIN_CSS_URL}]style.css" type="text/css" rel="stylesheet"/>
    <link href="[{$Think.const.ADMIN_CSS_URL}]common.css" type="text/css" rel="stylesheet"/>
    <link href="[{$Think.const.ADMIN_CSS_URL}]top_nav.css" type="text/css" rel="stylesheet"/>
    <script src="[{$Think.const.STATIC_URL}]js/jquery.min.js" type="text/javascript"></script>
</head>
<body>
<div id="top-nav">
    <ul>
        <li class="nav_li"><a href="[{$Think.const.APP_ADMIN_URL}]User/deluser">删除用户</a></li>
    </ul>
</div>
<table id="table1" class="table table-bordered table-hover definewidth m10" style="width:90%;">
    <thead>
    <tr>
        <th>用户ID</th>
        <th>用户名</th>
        <th>真实姓名</th>
        <th>学校</th>
        <th>手机号</th>
        <th>QQ</th>
        <th>邮箱</th>
        <th>注册ip</th>
        <th>用户注册时间</th>
        <th>操作</th>
    </tr>
    </thead>
    [{foreach userlist as $k=>$v }]
    <tr>
        <td>[{$v.user_id}]</td>
        <td>[{$v.username}]</td>
        <td>[{$v.account_name}]</td>
        <td>[{$v.school_id}]</td>
        <td>[{$v.user_tel}]</td>
        <td>[{$v.user_qq}]</td>
        <td>[{$v.user_email}]</td>
        <td>[{$v.ip}]</td>
        <td>[{$v.user_regtime}]</td>
        <td>
            <!--获取删除的user_id-->
            <a href="" value="[{$v.user_id}]">删除</a>
        </td>
    </tr>
    [{/foreach}]
</table>
<script>
    /*简单的jq，获取标签a点击的值*/
    $(document).ready(function () {
        $("#table1 a").click(function (e) {
            if (confirm("确定要删除吗？")) {
                var id = $(e.target).attr('value');
                /*用一个ajax把获取到的数据发送到后端去验证删除，无刷新删除*/
                $.ajax({
                    type: "POST",
                    url: "[{$Think.const.APP_ADMIN_URL}]User/deluser",
                    data: "user_id=" + id,
                    async: true, //默认为true 异步
                    error: function () {
                        alert('出错');
                    },
                    success: function (msg) {
                        if (msg == 'del success') {
                            alert('用户删除成功');
                            window.location.reload();
                        } else if (msg == 'error') {
                            alert('用户删除失败');
                            window.location.reload();
                        }
                    }
                });
            }
        });
    });
</script>
<div style="text-align:center;margin-top:15px;">[{$page}]</div>
</body>
</html>